//
//  HSYBaseViewController.m
//  HSY
//
//  Created by 陈浩 on 2017/4/1.
//  Copyright © 2017年 金开门. All rights reserved.
//

#import "HSYBaseViewController.h"
#import "BaseViewController+NavigationBar.h"
#import "UIImage+Tools.h"

@interface HSYBaseViewController ()

@end

@implementation HSYBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self setupNavigationBar:HSYNavgationBarTypeDefault];
    [self.titleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.rightAreaRBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [self.leftAreaLBtn setImage:[UIImage imageNamed:@"left_white"]  forState:UIControlStateNormal]; //默认显示返回
    [self.leftAreaLBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    self.leftAreaLBtn.contentHorizontalAlignment =  UIControlContentHorizontalAlignmentLeft;
    
    [self.leftAreaLBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftArea.mas_left);
        make.width.mas_equalTo(@60);
        make.centerY.mas_equalTo(self.leftArea.mas_centerY);
        make.height.mas_equalTo(@40);
    }];
    
    [self setupNavigationBarBackgroundImage]; //设置导航条背景图片（颜色）
    [self setupNavigationItemBackgroundColor]; //设置导航条上各个元素的背景色
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (self.hsy_whiteStatusBar) {
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; //默认状态栏颜色为白色
    }else{
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; //默认状态栏颜色为白色
    }
    [self.navigationController setNavigationBarHidden:NO animated:animated]; //默认显示导航条
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setupNavigationBarBackgroundImage{
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor hsyThemeColor] size:CGSizeMake(1, 1)]  forBarMetrics:UIBarMetricsDefault];
}

- (void)setupNavigationItemBackgroundColor{
    self.leftArea.backgroundColor = [UIColor clearColor];
    self.centerArea.backgroundColor = [UIColor clearColor];
    self.rightArea.backgroundColor = [UIColor clearColor];
    self.leftAreaLBtn.backgroundColor = [UIColor clearColor];
    self.leftAreaRBtn.backgroundColor = [UIColor clearColor];
    self.titleButton.backgroundColor = [UIColor clearColor];
    self.rightAreaLBtn.backgroundColor = [UIColor clearColor];
    self.rightAreaRBtn.backgroundColor = [UIColor clearColor];
}


- (BOOL)hsy_whiteStatusBar{
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
